package Messages;

import java.io.IOException;
import java.sql.SQLException;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * This class implements the delete Order from DB
 * @author Gabi Revah
 * @author Aviad Almog
 */ 
public class MessageDeleteOrder {
	private ConnectionToClient client ;
	private String[] str; 
	static int row1;
	int ordertemp;
/**
 * Contractor of this class 
 * @param str
 * @param client
 */
	public MessageDeleteOrder(String[] str, ConnectionToClient client){
		
		this.client= client ;
		this.str= str; 	
	
	}
	/**
	 * This method delete order from the DB 
	 * @throws SQLException
	 * @throws IOException
	 */
	public void DeleteOrder() throws SQLException, IOException{
		SQLConnection sc = new SQLConnection();

		java.sql.PreparedStatement ps=sc.getConnection().prepareStatement("DELETE FROM db.order where idOrder = ?;");
		java.sql.PreparedStatement ps1=sc.getConnection().prepareStatement("DELETE FROM db.assingment where idOrder = ?;");

		ps.setString(1,str[1]);
		ps1.setString(1,str[1]);
		ps.executeUpdate();
		ps1.executeUpdate();
		ps.close();
		ps1.close();
		
		client.sendToClient("OrderDelete");


		
	}
	

}
